VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Begin VB.Form frmPUR210 
   BackColor       =   &H00800000&
   Caption         =   "PUR200"
   ClientHeight    =   6795
   ClientLeft      =   690
   ClientTop       =   1305
   ClientWidth     =   10680
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   ScaleHeight     =   6795
   ScaleWidth      =   10680
   Begin MSAdodcLib.Adodc Adodc2 
      Height          =   330
      Left            =   8190
      Top             =   60
      Visible         =   0   'False
      Width           =   1815
      _ExtentX        =   3201
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc2"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSDataListLib.DataCombo cboFromVendor 
      Bindings        =   "frmPUR210.frx":0000
      Height          =   315
      Left            =   3930
      TabIndex        =   9
      Top             =   1275
      Width           =   1380
      _ExtentX        =   2434
      _ExtentY        =   556
      _Version        =   393216
      ListField       =   "VMNME"
      BoundColumn     =   "VMVDN"
      Text            =   ""
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "&Exit"
      Height          =   360
      Left            =   1260
      TabIndex        =   8
      Top             =   6345
      Width           =   1080
   End
   Begin VB.CommandButton cmdPrint 
      Caption         =   "&Print"
      Height          =   360
      Left            =   120
      TabIndex        =   7
      Top             =   6345
      Width           =   1080
   End
   Begin MSDataGridLib.DataGrid grdPO 
      Bindings        =   "frmPUR210.frx":0015
      Height          =   4515
      Left            =   120
      TabIndex        =   6
      Top             =   1740
      Width           =   10485
      _ExtentX        =   18494
      _ExtentY        =   7964
      _Version        =   393216
      HeadLines       =   1
      RowHeight       =   15
      FormatLocked    =   -1  'True
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ColumnCount     =   13
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   "OHPON"
         Caption         =   "PO No"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column02 
         DataField       =   "OHPOD"
         Caption         =   "PO Date"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column03 
         DataField       =   "OHPOT"
         Caption         =   "PO Type"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column04 
         DataField       =   "CMNME"
         Caption         =   "Customer"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column05 
         DataField       =   "OHCPO"
         Caption         =   "Cust Type"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column06 
         DataField       =   "VMNME"
         Caption         =   "Vendor"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column07 
         DataField       =   "OHCUR"
         Caption         =   "Cur Code"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column08 
         DataField       =   "OHRQD"
         Caption         =   "Request Date"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column09 
         DataField       =   "OHEXR"
         Caption         =   "Ex Rate"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column10 
         DataField       =   "OHTAM"
         Caption         =   "PO Amount"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column11 
         DataField       =   "OHBTA"
         Caption         =   "Base total"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column12 
         DataField       =   "OHPOS"
         Caption         =   "Status"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
            ColumnWidth     =   14.74
         EndProperty
         BeginProperty Column01 
            ColumnWidth     =   1154.835
         EndProperty
         BeginProperty Column02 
            ColumnWidth     =   975.118
         EndProperty
         BeginProperty Column03 
            ColumnWidth     =   764.787
         EndProperty
         BeginProperty Column04 
            ColumnWidth     =   1349.858
         EndProperty
         BeginProperty Column05 
            ColumnWidth     =   854.929
         EndProperty
         BeginProperty Column06 
            ColumnWidth     =   1590.236
         EndProperty
         BeginProperty Column07 
            ColumnWidth     =   824.882
         EndProperty
         BeginProperty Column08 
            ColumnWidth     =   14.74
         EndProperty
         BeginProperty Column09 
            ColumnWidth     =   675.213
         EndProperty
         BeginProperty Column10 
            ColumnWidth     =   959.811
         EndProperty
         BeginProperty Column11 
            ColumnWidth     =   824.882
         EndProperty
         BeginProperty Column12 
            ColumnWidth     =   659.906
         EndProperty
      EndProperty
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   330
      Left            =   5445
      Top             =   60
      Visible         =   0   'False
      Width           =   1755
      _ExtentX        =   3096
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.TextBox txtTo 
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   7.5
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   288
      Left            =   6660
      TabIndex        =   3
      Top             =   810
      Width           =   1110
   End
   Begin VB.TextBox txtFrom 
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   7.5
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   288
      Left            =   3945
      TabIndex        =   2
      Top             =   840
      Width           =   1065
   End
   Begin MSDataListLib.DataCombo cboToVendor 
      Bindings        =   "frmPUR210.frx":002A
      Height          =   315
      Left            =   6660
      TabIndex        =   12
      Top             =   1245
      Width           =   1380
      _ExtentX        =   2434
      _ExtentY        =   556
      _Version        =   393216
      ListField       =   "VMNME"
      BoundColumn     =   "VMVDN"
      Text            =   ""
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "From Vendor"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   7.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   255
      Index           =   5
      Left            =   2685
      TabIndex        =   11
      Top             =   1320
      Width           =   1110
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "To Vendor"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   7.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   255
      Index           =   4
      Left            =   5565
      TabIndex        =   10
      Top             =   1290
      Width           =   900
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "To PO"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   7.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   255
      Index           =   3
      Left            =   5580
      TabIndex        =   5
      Top             =   855
      Width           =   630
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "From PO"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   7.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   255
      Index           =   2
      Left            =   2700
      TabIndex        =   4
      Top             =   855
      Width           =   930
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "Purchase Order List by Item"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   16.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   465
      Index           =   1
      Left            =   3090
      TabIndex        =   1
      Top             =   225
      Width           =   5640
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "PUR210"
      BeginProperty Font 
         Name            =   "VNI-Present"
         Size            =   18
         Charset         =   0
         Weight          =   700
         Underline       =   -1  'True
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   465
      Index           =   0
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   1785
   End
End
Attribute VB_Name = "frmPUR210"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub cboToVendor_Click(Area As Integer)
If Area = 2 Then CalculatePO
End Sub

Private Sub cmdExit_Click()
Unload frmPUR210
End Sub

Private Sub txtfrom_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtTo.SetFocus

End Sub

Sub CalculatePO()
Dim recPOL, recPOH As Recordset, sumAmount, sumBAmount, txtOHPON
If cboFromVendor.BoundText <> "" And cboToVendor.BoundText <> "" Then
    Set recPOH = DBconn.Execute("Select * from POH where OHPON>='" & txtFrom & "' and OHPON<='" & txtTo & "' AND OHVDN>='" & cboFromVendor.BoundText & "' and OHVDN<='" & cboToVendor.BoundText & "'")
Else
    Set recPOH = DBconn.Execute("Select * from POH where OHPON>='" & txtFrom & "' and OHPON<='" & txtTo & "'")
End If
Do While Not recPOH.EOF
    txtOHPON = recPOH!OHPON
    Set recPOL = DBconn.Execute("SELECT PO.*,POL.* FROM POH RIGHT OUTER JOIN " & _
    "POL ON POH.OHPON = POL.OLPON where OLPON='" & txtOHPON & "' AND OLSTT<>'6'")
    sumAmount = 0
    sumBAmount = 0
    Do While Not recPOL.EOF
        If recPOL!OLPER = "1" Then
            sumBAmount = sumBAmount + ((recPOL!OLODQ * recPOL!OLUMP) - (recPOL!OLODQ * recPOL!OLUMP * recPOL!OLPDC))
        Else
            sumBAmount = sumBAmount + ((recPOL!OLODW * recPOL!OLUMP) - (recPOL!OLODW * recPOL!OLUMP * recPOL!OLPDC))
        End If
        sumAmount = sumBAmount * recPOL!OHEXR
        recPOL.MoveNext
    Loop
    SQL = "Update POH set OHTAM=" & sumAmount & ",OHBTA=" & sumBAmount & " where OHPON='" & txtOHPON & "'"
    recPOH.MoveNext
Loop
recPOL.Close
recPOH.Close

Adodc1.RecordSource = "SELECT POH.*,AVM.VMNME,RCM.CMNME FROM POH INNER JOIN" & _
    " RCM ON POH.OHCNO = RCM.CMCNO INNER JOIN AVM ON POH.OHVDN = AVM.VMVDN"
Adodc1.Refresh
End Sub
Sub OpenFile()
Adodc1.ConnectionString = ConnectString
Adodc1.ConnectionTimeout = 10
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "SELECT POH.*,AVM.VMNME,RCM.CMNME FROM POH INNER JOIN" & _
    " RCM ON POH.OHCNO = RCM.CMCNO INNER JOIN AVM ON POH.OHVDN = AVM.VMVDN"
Adodc1.Refresh

Adodc2.ConnectionString = ConnectString
Adodc2.ConnectionTimeout = 10
Adodc2.CommandType = adCmdText
Adodc2.RecordSource = "SELECT AVM.* FROM AVM"
Adodc2.Refresh
End Sub
